package com.sc.springboot.utils;

import com.sc.springboot.bean.ResultBean;

import java.util.List;

public class ResultUtil {

    public static ResultBean forResult(String resultCode, List data) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResultCode(resultCode);
        String resultMessage = "";
        switch (resultCode) {
            case "0":
                resultMessage = "成功";
                if (data != null && data.size() > 0) {
                    resultBean.setData(data);
                }
                break;
            case "1":
                resultMessage = "失败";
                break;
            case "2":
                resultMessage = "异常";
                break;
        }
        resultBean.setResultMessage(resultMessage);
        return resultBean;
    }
}
